package com.lemon.play.goai.posjudge.util;

import java.util.Enumeration;
import java.util.List;

/**
 * A tree structure.It can do anything.
 * 
 * @version 1.0 8/1/10
 * @author Dark_Light
 * @see java.util.Iterator
 * @see com.lemon.play.goai.posjudge.util.LinkedTree
 * @see java.util.Enumeration
 * @see java.util.List
 */
public interface Tree<T> extends Iterable<T> {

	/**
	 * Add a new element as a child of current element, and the current element
	 * will change to the new value.
	 * 
	 * @return the current element.
	 */
	Tree<T> add(T e);

	/**
	 * Add a tree,the children of the root in the tree will be as the children
	 * of current element.Current element do not change.
	 * 
	 * @return the current element.
	 */
	Tree<T> add(Tree<T> tree);

	/**
	 * 
	 * @see <code>getChildren()</code>
	 */
	List<T> getBrothers();

	List<T> getChildren();

	List<T> getChildren(T e);

	T getCurrent();

	T getParent();
	
	List<T> getPath();
	
	List<T> getPath(T e);

	T getAncester(int index);

	/**
	 * Remove current element, and the subTree of current will be remove too.The
	 * current element will change to its parent.
	 * 
	 * @return the current element.
	 */
	Tree<T> remove();

	Tree<T> removeInWhole(T e);

	Tree<T> removeBrother(T e);

	Tree<T> removeBrothers();

	Tree<T> removeChild(T e);

	Tree<T> removeChild(int index);

	Tree<T> removeChildren();

	Tree<T> removeParent();

	Tree<T> back();

	Tree<T> backToHead();

	Tree<T> setCurrentInWhole(T e);

	Tree<T> setCurrentInBrother(T e);

	Tree<T> setCurrentInChildren(T e);

	Tree<T> setCurrentInChildren(int index);

	Tree<T> subTree();

	Tree<T> clear();

	/**
	 * Insert the new element as new parent of current element, the old parent
	 * will be the parent of new parent.Then the current will change to the
	 * inserted element.
	 * 
	 * @return the current element.
	 */
	Tree<T> insert(T e);

	int getTreeDepth();

	int getDepth(T e);

	int getDepth();

	/**
	 * Get an enumeration of the tree that the enumeration will enumerate all
	 * the elements as depth-first traversal.
	 */
	Enumeration<T> getDepthFirstTraversal();

	/**
	 * Get an enumeration of the tree that the enumeration will enumerate all
	 * the elements as breadth-first traversal.
	 */
	Enumeration<T> getBreadthFirstTraversal();

	/**
	 * Remove current element, and the subTree of current will add to its parent
	 * as child.Current element change to its parent.
	 * 
	 * @return the current element.
	 */
	Tree<T> cut();

	Tree<T> cutInChildren(T e);

	Tree<T> cutInBrothers(T e);

	Tree<T> cutInWhole(T e);

	boolean isLeaf();

	boolean isLeaf(T e);
}
